<template>
	<view :class="currentTheme">
		<a-nabbar name="预约组局"/>
		<view class="u-padding-32">
			<item-box paddinglr="40">
				<label-box label="可否反串" labelWidth="200">
					<view class="u-flex" style="height: 64rpx;">
						<view v-for="(item, index) in reverseList" :key="index" :class="{'u-margin-left-30':index>0}">
							<v-radio :name="item.value"   v-model="form.isCrossTalk">
								<view class=" u-font-26 text-order-time" >{{item.label}}</view>
							</v-radio>
						</view>
					</view>
				</label-box>
				<label-box label="开始游戏时间" labelWidth="200">
					<select-item v-model="form.estimateTime" mode="time" secondType="hm"></select-item>
				</label-box>
				<label-box label="价格" labelWidth="200">
					<view class="u-flex">
						<view class="u-flex-1">
							<u-input placeholder=" " v-if="option.label=='线下'" v-model="form.intoPayMoney"
							:clearable="false" :borderColor="currentThemeObj.inputBorderColor" border type="digit"
									 :placeholder-style="`color:${currentThemeObj.placeholderColor}`"></u-input>
							<u-input placeholder=" " v-if="option.label=='线上'" v-model="form.onlineIntoPayMoney" 
							:borderColor="currentThemeObj.inputBorderColor" border type="digit"
									 :placeholder-style="`color:${currentThemeObj.placeholderColor}`">
								
							</u-input>
						</view>
						<text class="text-order-time u-margin-left-20">元/人</text>
					</view>
				</label-box>
				<label-box label="DM" labelWidth="200">
					<select-item v-model="form.dm" :list="personList" v-if="personList.length" @getIds="getIds"></select-item>
				</label-box>
			</item-box>
		</view>
		<fixed-team btnText="确定" @btnClick="save"></fixed-team>
	</view>
</template>

<script>
	import {getDetail,add} from '@/api/crud.js'
	import vRadio from '@/components/itemRadio/itemRadio.vue'
	export default {
		components: {
			vRadio
		},
		data() {
			return {
				form:{
					isCrossTalk:1,
					intoPayMoney:'',
					enrollTime:'',
					estimateTime:'',
					dm:''
				},
				personList:[],
				loading:false,
				apiModule:'shopApi',
				apiType:'gatherGame',
				option:{},
				reverseList:[{
					label:'可以',
					value:1
				},{
					label:'不可以',
					value:0
				}]
			};
		},
		onLoad(option) {
			this.form.intoPayMoney = option.intoPayMoney
			this.form.onlineIntoPayMoney = option.onlineIntoPayMoney
			this.option = option;
			getDetail(option,'systemStoreUser',this.apiModule,'list').then(res=>{
				this.personList = res.map(val=>({label:`${val.nickname}【${val.userType}】`,value:val.uid}));
			})
		}, 
		methods: {
			getIds(id){
				this.form.dmUid = id;
			},
			save() {
				let {dmUid,enrollTime,estimateTime,onlineIntoPayMoney,intoPayMoney} = this.form;
				if(!dmUid){
					this.$u.toast('请选择DM')
					return false;
				}
				if(!estimateTime){
					this.$u.toast('请选择开始游戏时间')
					return false;
				}
				if(onlineIntoPayMoney&&!this.$u.test.amount(onlineIntoPayMoney)){
					this.$u.toast('请输入正确的金额')
					return false;
				}
				if(intoPayMoney&&!this.$u.test.amount(intoPayMoney)){
					this.$u.toast('请输入正确的金额')
					return false;
				}
				let form = {...this.form,productId:this.option.id,storeId:this.option.storeId,uid:this.loginForm.uid}
				form.type = this.option.label=='线上' ? 1 : 0
				// form.enrollTime+=":00"
				form.estimateTime+=":00"  //后台需要完整的时分秒
				// if(new Date(enrollTime).getTime() > new Date(estimateTime).getTime()){
				// 	this.$u.toast('开始游戏时间不正确')
				// 	return false;
				// }
				add(form,this.apiType,this.apiModule).then(res=>{
					this.$u.toast('操作成功');
					
					this.$u.route({
						url:'/pagesA/storeAddLarp/detail',
						params:{
							type:'create',
							id:res
						}
					})
				})
			}
		},
	}
</script>

<style lang="scss" scoped>
.content{
	padding: 90rpx 52rpx;
}
.label-setting{
	width: 240rpx;
	line-height: 70rpx;
}
.diy-view{
	padding: 0px 10px;
	border:1px solid rgb(66, 63, 79);
	background-color: #161324;
	text-align: left;
	overflow: hidden;
	white-space: nowrap;  
	height: 70rpx;
	line-height: 70rpx;
	box-sizing: border-box;
	color: white;
	border-radius: 8rpx;
}
</style>
